package com.android.support.lib.universal.view.gridview;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.GridView;

/**
 * 重写GridView,禁止滑动。
 * 使用说明：
 * <com.android.support.lib.universal.view.gridview.BanGridView
        android:id="@+id/myGridView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/txtMsg"
        android:layout_centerHorizontal="true"
        android:numColumns="3" >
    </com.android.support.lib.universal.view.MyGridView>
 * @author 彭治铭
 *
 */
public class BanGridView extends GridView {

	public BanGridView(Context context) {
		super(context);
		// TODO Auto-generated constructor stub
	}

	public BanGridView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
		// TODO Auto-generated constructor stub
	}

	public BanGridView(Context context, AttributeSet attrs) {
		super(context, attrs);
		// TODO Auto-generated constructor stub
	}

	@Override
	public boolean dispatchTouchEvent(MotionEvent ev) {
		// TODO Auto-generated method stub
		if (ev.getAction() == MotionEvent.ACTION_MOVE) {
			return true; // 禁止GridView滑动
		}
		return super.dispatchTouchEvent(ev);
	}

}
